package com.test.utils;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class CommonMethods {


    public static void waitElementExist( WebDriver driver,By by,int seconds){
        try {
            for (int i=0;i<seconds;i++){
                boolean elementExist=byElementIsExist(driver,by);
                if (elementExist!=true){
                    Thread.sleep(1000);
                }
               else {break;}
                System.out.println("等待元素"+by+"出现已用"+i+"秒");
            }
        }
        catch (Exception E){}
    }
    public static Boolean byElementIsExist( WebDriver driver,By by) {
        try {
            driver.findElement(by);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
